//
//  FriendCricleMediaCell.swift
//  jiahui
//
//  Created by 3tee on 2024/12/13.
//

import UIKit
import SnapKit

class FriendCricleMediaCell: UICollectionViewCell {
    
    typealias gestureClosure = (FriendCricleMediaCell) -> Void
    
    var gestureHandler: gestureClosure?
    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    func setupUI() {
        self.contentView.addSubview(imgV)
        imgV.snp.makeConstraints { make in
            
            make.edges.equalTo(contentView)
        }
    }
    
    lazy var imgV: UIImageView = {
        let imgv = UIImageView()
        imgv.contentMode = .scaleAspectFit
        let gester = UITapGestureRecognizer(target: self, action: #selector(imgTaped))
        imgv.addGestureRecognizer(gester)
        imgv.isUserInteractionEnabled = true
        return imgv
    }()

    @objc func imgTaped() {
        print("当前图片被点击了")
       
       gestureHandler?(self)
    }
    
}

func fetchData() async -> String{
    sleep(2)
    return "数据获取成功"
}

func processData() async  {
    let data = await fetchData()
    print("数据处理成功")
}
